(function($, doc) {
	$.init({});		
	var userinfo = app.getState() || {};
	
	$.plusReady(function() {
		doc.getElementById('phone').value=userinfo.mobile
		
		var findButton = doc.getElementById('reg_btn');
		var phoneBox = doc.getElementById('phone');
		var passwordBox = doc.getElementById('password');
		var codeBox = doc.getElementById('code');
		
		findButton.addEventListener('tap', function(){
			var loginInfo = {
				account: phoneBox.value,
				code: codeBox.value,
				password: passwordBox.value
			};
			var num = /^\d{6}$/;
			
			if(loginInfo.account=='') {
				plus.nativeUI.toast('请输入手机号');
				return;
			}
			if(loginInfo.code=='') {
				plus.nativeUI.toast('请输入验证码');
				return;
			}
			
			if(!num.exec(loginInfo.password)){
           		  plus.nativeUI.toast('支付密码只能为6位纯数字！');
           		  return false;
           	}
			
			mui.ajax({
				url: apiurl + "Login/find_tradepwd/",
				data: loginInfo,
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'post',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status < 1) {
						mui.toast(res.msg);
					} else {
						mui.alert(res.msg);
						mui.back();
					}
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('找回支付密码失败！');
				}
			});
			
		}, false);
		
		
	});
}(mui, document));